#!/usr/bin/env bash
#########################################################################
# File Name   : nova.sh.j2
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: Mon 2024-09-30 13:17:38(+0800)
#########################################################################

#
#
# Usage:

{
  set -euo pipefail
  # set -E
  #     If set, any trap on ERR is inherited by shell functions, command
  #     substitutions, and commands executed in a subshell environment.

}

source /root/keystonerc

# create [neutron] user in [service] project
openstack --insecure user create --domain default --project service --password {{ service_password }} neutron

# add [neutron] user in [admin] role
openstack --insecure role add --project service --user neutron admin
# create service entry for [neutron]
openstack --insecure service create --name neutron --description "OpenStack Networking service" network

# define Neutron API Host
export controller={{ openstack_neutron_ip }}
# create endpoint for [neutron] (public)
openstack --insecure endpoint create --region RegionOne network public https://$controller:9696

# create endpoint for [neutron] (internal)
openstack --insecure endpoint create --region RegionOne network internal https://$controller:9696

# create endpoint for [neutron] (admin)
openstack --insecure endpoint create --region RegionOne network admin https://$controller:9696
